import { Button } from "antd"
import { carAuthStatusList, custTypesList, entryStatusList, fundingPartyList, tabs } from "../../enum"
import { getEnumLabel } from "../../utils"

interface operationRenderProps {
    item?: any
    props: any
    dealEntry: Function
}

export const getColumns = ({ props, dealEntry }: operationRenderProps) => {
    return [
        { title: '进件编号', dataIndex: 'entryNo', width: 150 },
        { title: '客户名称', dataIndex: 'custName', width: 100, ellipsis: true },
        { title: '证件号', dataIndex: 'idNo', width: 180 },
        { title: '客户类型', dataIndex: 'custType', width: 80, render: (text: string) => getEnumLabel(custTypesList, text) },
        { title: '客户等级', dataIndex: 'custLevel', width: 80 },
        { title: '客户认证情况', dataIndex: 'kkCarAuthStatus', render: (text: string) => getEnumLabel(carAuthStatusList, text) },
        { title: '风控结果', dataIndex: 'riskResult', ellipsis: true },
        { title: '状态', dataIndex: 'entryStatus', render: (text: string) => getEnumLabel(entryStatusList, text), width: 100 },
        { title: '操作', width: 180, render: (v: any) => operationRender({ item: v, props, dealEntry }), key: 'operation' }
    ]
}

const operationRender = ({ item, props, dealEntry }: operationRenderProps) => {
    const WAIT_TO_DEAL = props.entryStatus === entryStatusList[1].value
    const NOT_PSBC = item.fundingParty !== fundingPartyList[3].value
    const NOT_PSBC_NON_GUARANTEE = item.fundingParty !== fundingPartyList[4].value
    const SHOW = [tabs[1].key, tabs[2].key, tabs[3].key].includes(props.entryStatus) || [entryStatusList[2].value, entryStatusList[3].value].includes(item.entryStatus)
    const MATCHLIST = [entryStatusList[5].value, entryStatusList[6].value, entryStatusList[7].value, entryStatusList[8].value, entryStatusList[9].value].includes(item.entryStatus)
    return <>
        {SHOW ? <Button type="link">查看</Button> : null}
        {WAIT_TO_DEAL ? <Button onClick={() => dealEntry(item)} type="link">进件处理</Button> : null}
        {WAIT_TO_DEAL && !NOT_PSBC ? <Button type="link">转交</Button> : null}
        {WAIT_TO_DEAL ? <Button type="link">撤销</Button> : null}
        {MATCHLIST && NOT_PSBC && NOT_PSBC_NON_GUARANTEE ? <Button type="link">重走授信</Button> : null}
    </>
}

const TableColums = () => {
    return null
}

export default TableColums